<template>
  <div class="article-items">
    <!-- 文章列表用到的组件 -->
    <!-- 用到单元格 -->
    <van-cell size="large">
      <template #title>
        <!-- 标题插槽 -->
        <p class="article-title van-multi-ellipsis--l2">{{article.title}}</p>
      </template>
      <template #default>
        <!-- 一个图片默认插槽,自定义右侧  -->
        <div class="cover-1" v-if="article.cover.type==1">
          <van-image fit="cover" class="cover-1-item" :src="article.cover.images[0]" />
        </div>
      </template>
      <template #label>
        <!--  三个图片时显示在标题下方 -->
        <div class="cover-3" v-if="article.cover.type==3">
          <van-image
            fit="cover"
            v-for="(item,index) in article.cover.images"
            :key="index"
            class="cover-3-item"
            :src="item"
          />
        </div>
        <div class="article-labels">
          <span>{{article.aut_name}}</span>
          <span>{{article.comm_count}}</span>
          <span>{{article.pubdate|relativeTime}}</span>
        </div>
      </template>
    </van-cell>
  </div>
</template>

<script>
export default {
  props: {
    article: {
      type: Object,
      require: true
    }
  },
  data() {
    return {}
  },
  methods: {}
}
</script>

<style lang='less' scoped>
.article-items {
  border-bottom: 1px solid #edeff3;
  .article-title {
    margin: 0;
    padding: 0;
    font-size: 32px;
    color: #3a3a3a;
  }
  .van-cell__title {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }
  .van-cell__value {
    flex: unset;
  }
  .cover-1 {
    .cover-1-item {
      width: 232px;
      height: 146px;
      margin-left: 25px;
    }
  }
  .cover-3 {
    display: flex;
    padding: 30px 0;
    .cover-3-item {
      flex: 1;
      height: 146px;
      &:not(:last-of-type) {
        margin-right: 4px;
      }
    }
  }
  .article-labels {
    margin-bottom: 0px;
    span {
      font-size: 22px;
      color: #b4b4b4;
      margin-right: 25px;
    }
  }
}
</style>
